<?php
/**
 * Created by PhpStorm.
 * User: mayn
 * Date: 2020/9/2
 * Time: 15:14
 */
require_once 'RedisAbstract.php';
class Sign extends RedisAbstract
{
    public $keySign = 'sign';//签到记录key
    public function __construct($userId, $year, $month)
    {
        parent::__construct();
        //设置当前用户 签到记录的key
        $this->keySign = $this->keySign . '_' . $year . '_' . $month . ':' . $userId;
    }

    /**
     * 用户签到
     * @param $day
     * @return int|null
     * @throws \Exception
     * @author wenzhen-chen
     */
    public function setSignLog($day)
    {
        return $this->setBit($this->keySign, $day, 1);
    }

    /**
     * 查询签到记录
     * @param $day
     * @return int|null
     * @throws \Exception
     * @author wenzhen-chen
     */
    public function getSignLog($userId,$day)
    {
        return $this->getBit($this->keySign, $day);
    }

    /**
     * 删除签到记录
     * @return int|null
     * @throws \Exception
     * @author wenzhen-chen
     */
    public function delSignLig()
    {
        return $this->del($this->keySign);
    }

}